<template>
  <el-container class="container">
    <el-header class="header _border-bottom" height="126px">
      <h1 class="logo">
        <img src="../../assets/logo.png" style="height: 50px" />
      </h1>
      <img src="../../assets/login/slogan.png" />
    </el-header>
    <el-main class="main">
      <div class="form-block" id="formBlock">
        <div class="form">
          <img src="../../assets/logo.png" />
          <div class="welcome-banner">欢迎来到1996游戏平台</div>
          <component :is="compon"></component>
          <div class="login-mode">
            <el-button v-show="compon !== 'PasswordLogin'" size="mini" plain @click="passwordLoginMode" class="">账号登录</el-button>
            <el-button v-show="compon !== 'PhoneLogin'" size="mini" plain @click="PhoneLogin" class="">手机登录</el-button>
            <el-button v-show="compon !== 'DingTalkLogin'" size="mini" plain @click="dingTalkLogin">钉钉登录</el-button>
            <el-button v-show="compon !== 'WeChatLogin'" size="mini" plain @click="weChatLogin">微信登录</el-button>
          </div>
        </div>
      </div>
    </el-main>
    <el-footer class="_el-pagination" style="border-top: 1px solid #F2F2F4;" height="126px">
      <span>经营许可证：桂B2-20200032 桂ICP备18004203号-1 桂网文{2018} 10356-049号</span>
      <!-- <span>Copyright@2020-2021一九九六</span> -->
    </el-footer>
  </el-container>
</template>

<script>
import PhoneLogin from './components/PhoneLogin'
import PasswordLogin from './components/PasswordLogin'
import DingTalkLogin from './components/DingTalkLogin'
import WeChatLogin from './components/WeChatLogin'

export default {
  name: 'Login',
  components: {
    PhoneLogin,
    PasswordLogin,
    DingTalkLogin,
    WeChatLogin
  },
  data () {
    return {
      compon: 'PhoneLogin'
    }
  },

  mounted () {
    // this.$store.commit('logout')
    this.$nextTick().then(() => {
      this.scroll()
    })
  },
  methods: {
    dingTalkLogin () {
      this.compon = 'DingTalkLogin'
    },
    passwordLoginMode () {
      this.compon = 'PasswordLogin'
    },
    PhoneLogin () {
      this.compon = 'PhoneLogin'
    },
    weChatLogin () {
      this.compon = 'WeChatLogin'
    },
    scroll () {
      setTimeout(() => {
        const formBlock = document.getElementById('formBlock')
        formBlock.style.animation = 'slide 30s linear 0s infinite'
        const width = window.getComputedStyle(formBlock).width
        const styleSheets = document.styleSheets
        let domStyle
        for (let i = 0; i < styleSheets.length; i++) {
          const cssStyle = styleSheets[i]
          try {
            if (cssStyle.cssRules.length > 1) {
              domStyle = cssStyle
              break
            }
          } catch (e) {
            // continue
          }
        }
        domStyle.insertRule(
            `@keyframes slide {
            from { background-position: 0px center; }
            to { background-position: -${width} center; }
          }`,
            domStyle.length
        )
      }, 500)
    }
  }
}
</script>

<style scoped lang="scss">
.margin {
  margin-top: 10px;
  margin-bottom: 10px;
}

.submit {
  text-align: center;
}
.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;

  .header {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    // height: 80px;
    width: 100%;
    max-width: 1200px;
    padding: 0;

    .logo {
      object-fit: scale-down;
      height: 30px;
      width: 150px;
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      align-items: center;
    }
  }

  .main {
    background: #F8F7FC;
    display: flex;
    flex: 1;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;

    .form-block {
      width: 100vw;
      display: flex;
      justify-content: center;
      align-items: center;
      -moz-background-size: auto 60%; /* 老版本的 Firefox */
      background-size: auto 60%;
      -webkit-background-origin: content-box; /* Safari */
      background-origin: content-box;
      background: url("../../assets/login/logo-bg.png") repeat-x center;

      .form {
        padding: 93px 185px;
        box-shadow: 0px 8px 26px 0 rgba(0, 0, 0, 0.06);
        border-radius: 5px;
        width: 336px;
        background: white;
        text-align: center;

        .welcome-banner {
          font-size: 23px;
          font-weight: 400;
          font-style: italic;
          color: #142338;
          margin: 15px auto;
          line-height: 48px;
        }
      }
    }
  }

  ._el-pagination {
    height: 126px;
    width: 100%;
    max-width: 1200px;
    text-align: center;
    padding: 0;
    display: flex;
    font-size: 12px;
    flex-direction: column;
    line-height: 30px;
    color: #abacb0;
    span {
      padding-top: 30px;
    }
  }
}
</style>
